package com.hqyj.controller;


import com.hqyj.pojo.PaperQuestion;
import com.hqyj.pojo.R;
import com.hqyj.service.PaperQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author rock
 * @since 2022-10-25 02:07:10
 */
@RestController
@RequestMapping("/paper-question")
public class PaperQuestionController {

    @Autowired
    PaperQuestionService paperQuestionService;

    //增，删，改，查
    @PostMapping("/paper/{method}")
    public R  addDelUpdate(@PathVariable("method") String method, PaperQuestion paperQuestion) throws ParseException {
        switch (method){
            case "add":
               return paperQuestionService.add(paperQuestion);
            case "del":
                return paperQuestionService.del(paperQuestion.getQuId());
            case "update":
                return paperQuestionService.update(paperQuestion);
            case "query":
                return paperQuestionService.query(paperQuestion);
             default:
                 return R.error("请求地址不正确");
        }

    }


}

